﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Locadora.TOB;

namespace Locadora.BLL.DAL
{
    internal static class ClassificacaoDAL
    {
        internal static int GetTotalClassificacao(string id)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            int total = dc.TB_CLASSIFICACAOs.Where(c => c.GD_USUARIO == id).Count();
            dc.Dispose();
            return total;
        }

        internal static List<Locadora.TOB.TB_CLASSIFICACAO> GetClassificacao(int start, int offset, string id)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            var users = dc.TB_CLASSIFICACAOs.Where(c => c.GD_USUARIO == id).Skip(start).Take(offset);
            List<TB_CLASSIFICACAO> lista=null;
            foreach (var item in users)
            {
                lista = users.ToList<TB_CLASSIFICACAO>();
                break;
            }
            dc.Dispose();
            return lista;
        }

        internal static void Inserir(TB_CLASSIFICACAO tb)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            dc.TB_CLASSIFICACAOs.InsertOnSubmit(tb);
            dc.SubmitChanges();
            dc.Dispose();
        }

        internal static int GetTotalClassificacaoPos(string id)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            int total = dc.TB_CLASSIFICACAOs.Where(c => c.GD_USUARIO == id && c.TP_CLASSIFICACAO==true).Count();
            dc.Dispose();
            return total;
        }

        internal static int GetTotalClassificacaoNeg(string id)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            int total = dc.TB_CLASSIFICACAOs.Where(c => c.GD_USUARIO == id && c.TP_CLASSIFICACAO==false).Count();
            dc.Dispose();
            return total;
        }
    }
}
